﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ControlBaoCaoDoanhSoNgayChuaKhoaSo.ascx.cs" Inherits="WebUserControl_ControlBaoCaoDoanhSoNgayChuaKhoaSo" %>

<%@ Register src="uscMsgBox.ascx" tagname="uscMsgBox" tagprefix="uc1" %>


 <%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPivotGrid" tagprefix="dxwpg" %>

<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v9.2.Export, Version=9.2.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.XtraPivotGrid.Web" tagprefix="dxpgw" %>

<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/K_BaoCaoFormLayout.css")%>' type="text/css" />
<link rel="stylesheet" href='<%=ResolveUrl("~/LayoutCss/datePicker.css")%>' type="text/css" />


<script type="text/javascript">
     function pageLoad() {
     
      $(function()
        {
	            $("#<%= txtFromDate.ClientID %>").datePicker(
	                {
	                    clickInput:true,
			            startDate: '01/01/1970'
	                }
	                );
        });
	            
	            $("#<%= txtFromDate.ClientID %>").bind(
		            'dpClosed',function(e, selectedDates)
		                        {
			                        var d = selectedDates[0];
			                        if (d) {
				                            d = new Date(d);
				                            $("#<%= txtToDate.ClientID %>").dpSetStartDate(d.addDays(0).asString());
			                                }
		                        }
	                    );
	                    
	     $(function()
        {
	            $("#<%= txtToDate.ClientID %>").datePicker(
	                {
	                    clickInput:true
			           
	                }
	                );
        });
	
	          $("#<%= txtToDate.ClientID %>").bind(
		           'dpClosed',function(e, selectedDates)
		                        {
			                        var d = selectedDates[0];
			                        if (d) {
				                            d = new Date(d);
				                            $("#<%= txtFromDate.ClientID %>").dpSetEndDate(d.addDays(0).asString());
			                                }
		                        }
	            );

     
       $("#<%= Button1.ClientID %>").click(function() { 
       if ($("#<%= txtFromDate.ClientID %>").val().length>0 && $("#<%= txtToDate.ClientID %>").val().length>0)
            {
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff' 
        } });
        } 
        }); 
        $("#<%= Button2.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff'
        } }); 
         setTimeout($.unblockUI, 5000); 
        }); 
         $("#<%= btPrint.ClientID %>").click(function() { 
        $.blockUI({
             message: '<h1>Xin vui lòng chờ xử lý</h1>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#f00', 
            opacity: .5, 
            color: '#fff'
        } }); 
         setTimeout($.unblockUI, 5000); 
        }); 
        
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
                function EndRequestHandler(sender, args) {
                        $.unblockUI();
                }
        }  
   
</script>  
  
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
     <fieldset>
    <legend>Báo cáo doanh số ngày</legend>
    <div class="fm-req">
      <label for="DropDownList1">TTPP:</label>
       <asp:DropDownList Width="200px" ID="DropTTPP"  runat="server">
                    </asp:DropDownList>
      </div>
      <div class="fm-req">
      <label for="txtFromDate">Từ ngày:</label>
      <asp:TextBox ID="txtFromDate" runat="server"></asp:TextBox>
       <asp:RequiredFieldValidator ControlToValidate="txtFromDate" Display="None" ID="RequiredFieldValidator1" runat="server" ErrorMessage="Phải chọn thời gian">
                    </asp:RequiredFieldValidator>
                    <AjaxControls:ValidatorCalloutExtender TargetControlID="RequiredFieldValidator1" ID="ValidatorCalloutExtender1" runat="server">
                    </AjaxControls:ValidatorCalloutExtender>
      </div>
       <div class="fm-req">
      <label for="txtFromDate">Đến ngày:</label>
      <asp:TextBox ID="txtToDate" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ControlToValidate="txtToDate" Display="None" ID="RequiredFieldValidator2" runat="server" ErrorMessage="Phải chọn thời gian">
                    </asp:RequiredFieldValidator>
                    <AjaxControls:ValidatorCalloutExtender TargetControlID="RequiredFieldValidator2" ID="ValidatorCalloutExtender2" runat="server">
                    </AjaxControls:ValidatorCalloutExtender>
      </fieldset>
        <uc1:uscMsgBox ID="uscMsgBox1"  runat="server" />

       <div>
                    <asp:Button ID="Button1" runat="server" Text="Báo cáo" 
                        onclick="Button1_Click" />
                    &nbsp;&nbsp;<asp:Button ID="btPrint" runat="server" Text="Xuất ra Excel"  CausesValidation="false"
                        onclick="btPrint_Click" />
                    &nbsp;&nbsp;<asp:Button  ID="Button2" 
                        runat="server" Text="Xuất ra Excel Pivot" onclick="Button2_Click" CausesValidation="false" />
                    
           </div>
        
      
        <br />
        
         <dxwpg:ASPxPivotGrid ID="ASPxPivotGrid1" runat="server" 
            CustomizationFieldsVisible="True" CustomizationFieldsLeft="700" 
            CustomizationFieldsTop="400">
             <Fields>
                 <dxwpg:PivotGridField ID="field" Area="RowArea" AreaIndex="2" 
                     Caption="Nhãn hiệu" FieldName="InclassName" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field1" Area="RowArea" AreaIndex="2" 
                     Caption="Sản phẩm" FieldName="ProductName" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field2" Area="RowArea" AreaIndex="2" 
                     Caption="Ngành hàng" FieldName="CommodName" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field3" Area="RowArea" AreaIndex="2" 
                     Caption="Mặt hàng" FieldName="ItemName" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field4" Area="RowArea" AreaIndex="0" 
                     Caption="Trung tâm phân phối" FieldName="SiteCode">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field5" Area="RowArea" AreaIndex="2" 
                     Caption="Mã hàng" FieldName="SkuCode" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field6" Area="RowArea" AreaIndex="2" 
                     Caption="Mã tư vấn viên" FieldName="salespkey" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field7" Area="RowArea" AreaIndex="2" 
                     Caption="Số lượng" FieldName="OffQty" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field8" Area="ColumnArea" AreaIndex="0" 
                     Caption="Ngày" FieldName="OffDate">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field9" Area="DataArea" AreaIndex="0" 
                     Caption="Số tiền" CellFormat-FormatString="{0:###,###.###}" 
                     CellFormat-FormatType="Numeric" FieldName="OffAmt">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field10" Area="RowArea" AreaIndex="3" 
                     Caption="Tên tư vấn viên" FieldName="salespname" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field11" Area="RowArea" AreaIndex="3" Caption="Tỉnh" 
                     FieldName="mprovince" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field12" Area="RowArea" AreaIndex="3" Caption="Quận" 
                     FieldName="mTown" Visible="False">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField ID="field13" Area="RowArea" AreaIndex="1" 
                     Caption="Tư vấn viên" FieldName="TVV">
                 </dxwpg:PivotGridField>
                  <dxwpg:PivotGridField ID="Field14" Area="RowArea" AreaIndex="3" Caption="Loại doanh số" 
                     FieldName="OffType" Visible="False">
                 </dxwpg:PivotGridField>
                  <dxwpg:PivotGridField ID="Field15" Area="RowArea" AreaIndex="3" Caption="Loại dòng" 
                     FieldName="ProgramID" Visible="False">
                 </dxwpg:PivotGridField>
                  <dxwpg:PivotGridField ID="Field16" Area="RowArea" AreaIndex="3" Caption="Nhóm trưởng" 
                     FieldName="TeamLeader" Visible="False">
                 </dxwpg:PivotGridField>
                  <dxwpg:PivotGridField HeaderStyle-BackColor="Yellow" ID="PivotGridField1" Area="FilterArea" AreaIndex="0" Caption="Báo cáo doanh số ngày" 
                     FieldName="Baocao" Visible="True">
                 </dxwpg:PivotGridField>
                  <dxwpg:PivotGridField HeaderStyle-BackColor="Yellow" ID="PivotGridField2" Area="FilterArea" AreaIndex="1" Caption="Từ ngày : " 
                     FieldName="FromDate" Visible="True">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField HeaderStyle-BackColor="Yellow" ID="PivotGridField3" Area="FilterArea" AreaIndex="2" Caption="Đến ngày : " 
                     FieldName="ToDate" Visible="True">
                 </dxwpg:PivotGridField>
                 <dxwpg:PivotGridField HeaderStyle-BackColor="Yellow" ID="PivotGridField4" Area="FilterArea" AreaIndex="3" Caption="Giờ : " 
                     FieldName="Time" Visible="True">
                 </dxwpg:PivotGridField>
             </Fields>
        </dxwpg:ASPxPivotGrid>
        
        <br />
         <dxpgw:ASPxPivotGridExporter ASPxPivotGridID="ASPxPivotGrid1" ID="ASPxPivotGridExporter1" runat="server">
        </dxpgw:ASPxPivotGridExporter>

        
    
           
    </ContentTemplate>
    <Triggers>
     <asp:PostBackTrigger ControlID="btPrint" />
     <asp:PostBackTrigger ControlID="Button2" />
    </Triggers>
</asp:UpdatePanel>











